import 'package:myapp/entities/entities.dart';
import 'package:myapp/models/models.dart';

class MyUserEntity {
  String userId;
  String email;
  String name;
  Profile profile;

  MyUserEntity({
    required this.userId,
    required this.email,
    required this.name,
    required this.profile
  });

  Map<String, Object?> toDocument() {
    return {
      'userId': userId,
      'email': email,
      'name': name,
      'profile': profile.toEntity().toDocument()
    };
  }

  static MyUserEntity fromDocument(Map<String, dynamic> doc) {
    return MyUserEntity(
      userId: doc['userId'],
      email: doc['email'],
      name: doc['name'],
      // profile: MyUser.fromEntity(MyUserEntity.fromDocument(doc['author']))
      profile: Profile.fromEntity(ProfileEntity.fromDocument(doc['profile']))
    );
  }
}
